<?php
/**
 * 厅主管理游戏开关
 * User: 胡诚
 * Date: 2018/11/9
 * Time: 12:02
 */

namespace App\Controllers;

use App\Services\HallBasicService;
use Illuminate\Http\Request;

class HallBasicController extends BaseController
{
//    public $allows = ['getHallBasic', 'updateHallGameConfig'];

    /**
     * 获取厅主游戏开关数据
     * @param Request $request
     * @return mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function getHallBasic(Request $request)
    {
        $this->validate($request, [
            'hall_id' => 'required|integer',
        ]);
        $hallId = $request->input('hall_id');
        $res    = HallBasicService::getValues($hallId);
        
        $res['balance'] = amount_format($res['balance']);
        return $res;
    }

    /**
     * 修改客户基本数据
     * @param Request $request
     * @return mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function updateHallBasic(Request $request)
    {
        $this->validate($request, [
            'hall_id'        => 'required|integer',
            'company_name'   => 'string',
            'mobile'         => 'integer',
            'email'          => 'email',
            'emergency_code' => 'required',
            'emergency'      => 'required',
        ], [
            'email'  => 'email必须是邮箱',
            'mobile' => 'mobile必须是整数',
        ]);
        $hallId = $request->input('hall_id');
        $value  = $request->input();
        return HallBasicService::editBasicData($hallId, $value);
    }
}
